package  SEApp.components.propertyCtrls {
	import UIFree.graphicTools.color.uif_gradientPalette;
	import UIFree.graphicTools.color.uif_spectrumPalette;
	import UIFree.uif_component;
	
	import flash.events.Event;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	
	public class c_colorPicker extends c_propertyBase {
		public static const WEIGHT: Number = 200;
		private var _palette: uif_gradientPalette;
		private var _spectum: uif_spectrumPalette;
		
		public function c_colorPicker(parent:uif_component, aData:Object, y:Number, a_height:Number) {
			super(parent, aData, y, a_height);
		}
		
		override protected function createComponents():void {
			super.createComponents();
			var rect: Rectangle = componentRect;
			var bh: Number = 50; 
			
			_palette = new uif_gradientPalette(this, rect.x, rect.y, rect.width - bh, rect.height, 'paletteCtrl');
			_palette.addEvent(Event.CHANGE, doChange);
			
			_spectum = new uif_spectrumPalette(this, 0, 0, rect.height, bh, 'paletteCtrl');
			_spectum.rotation = 90;
			_spectum.position = new Point(rect.x + rect.width, rect.y);
			_spectum.addEvent(Event.CHANGE, doBaseColorChange);
			
			_palette.baseColor = 0xFF0000;
		}
		
		protected function doBaseColorChange(e: Event): void {
			_palette.baseColor = _spectum.selectColor;
			_palette.selectColor = _palette.baseColor; 
		}
		
		override protected function getValue(): Object {
			return _palette.selectColor;
		}		
	}
}